package com.artieksi.entity.rowmapper;

import com.artieksi.entity.SignBean;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * User: TTACANSEVER
 */
public class SignBeanRowMapper implements ParameterizedRowMapper<SignBean> {
    private String sign;

    public SignBeanRowMapper(String sign) {
        this.sign = sign;
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    @Override
    public SignBean mapRow(ResultSet rs, int i) throws SQLException {
        SignBean signBean = new SignBean();
        signBean.setUsername(rs.getString("signed_username"));
        try {
            signBean.setCount(rs.getInt("c"));
        } catch (Exception ex) {
            signBean.setText(rs.getString("text"));
        }
        try {
            signBean.setSignTime(rs.getTimestamp("sign_time"));
        } catch (Exception ex) {

        }
        signBean.setSign(sign);
        signBean.setPictureUrl(rs.getString("picture_url"));
        return signBean;
    }
}
